package com.pd;

import com.pd.pojo.PdOrder;
import com.pd.service.OrderService;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@RabbitListener(queues = "orderQueue")
@Component
public class OrderConsumer {
    @Autowired
    private OrderService orderService;
    @RabbitHandler
    public void receive(PdOrder order) throws Exception {
        orderService.saveOrder(order);
        System.out.println("----订单已存储----");
    }
}
